home *** CD-ROM | disk | FTP | other *** search
/ Aminet 44 / Aminet 44 (2001)(GTI - Schatztruhe)[!][Aug 2001].iso / Aminet / util / misc / ReportPlus.lha / reportplus / source / te.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-06-25  |  23.3 KB  |  587 lines

  1. /* $Filename:    ReportPlus/Source/te.c
  2.  * $VER:         Report+ 4.63b
  3.  * $Description: ReAction gadgets (text editor) for Report+
  4.  *
  5.  * © Copyright 2001 James R. Jacobs. Freely distributable.
  6.  *        _
  7.  *       //      -=AMIGA=-
  8.  *      //
  9.  * _   //
  10.  * \\ //
  11.  *  \X/
  12.  *
  13.  * Used only for functions 1 and 4. */
  14.  
  15. // system includes
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19.  
  20. #include <exec/types.h>
  21. #include <exec/memory.h>
  22. #include <intuition/intuition.h>
  23. #include <intuition/gadgetclass.h>
  24. #include <libraries/gadtools.h>
  25. #include <graphics/gfxbase.h>
  26. #include <graphics/text.h>
  27. #include <utility/tagitem.h>
  28. #include <utility/hooks.h>
  29. #include <workbench/startup.h>
  30. #include <workbench/workbench.h>
  31.  
  32. #include <proto/intuition.h>
  33. #include <clib/graphics_protos.h>
  34. #include <proto/exec.h>
  35. #include <proto/dos.h>
  36. #include <proto/utility.h>
  37. #include <proto/wb.h>
  38. #include <proto/icon.h>
  39.  
  40. #include <clib/alib_protos.h>
  41. #include <clib/texteditor_protos.h>
  42.  
  43. // ReAction includes
  44. #define ALL_REACTION_CLASSES
  45. #define ALL_REACTION_MACROS
  46. #include <reaction/reaction.h>
  47.  
  48. #include <gadgets/texteditor.h>
  49. #include <pragmas/texteditor_pragmas.h>
  50.  
  51. #include "amigan.h"
  52.  
  53. #define ASM    __asm
  54. #define REG(x) register __ ## x
  55.  
  56. enum
  57. {   GID_MAIN = 0,
  58.     GID_TEXTEDITOR1,
  59.     GID_TEXTEDITOR2,
  60.     GID_TEXTEDITOR3,
  61.     GID_TEXTEDITOR4,
  62.     GID_TEXTEDITOR5,
  63.     GID_TEXTEDITOR6,
  64.     GID_TEXTEDITOR7,
  65.     GID_TEXTEDITOR8,
  66.     GID_TEXTEDITOR9,
  67.     GID_TEXTEDITOR10,
  68.     GID_TEXTEDITOR11,
  69.     GID_TEXTEDITOR12,
  70.     GID_TEXTEDITOR13,
  71.     GID_TEXTEDITOR14,
  72.     GID_DOWN,
  73.     GID_UP,
  74.     GID_OK,
  75.     GID_LAST
  76. };
  77.  
  78. enum
  79. {   OID_MAIN = 0,
  80.     OID_LAST
  81. };
  82.  
  83. MODULE STRPTR               textBuffer[MAXELEMENTS + 1];
  84.  
  85. // from f4.c
  86. IMPORT UBYTE*               StarBufferPtr[MAXELEMENTS + 1];
  87. IMPORT ULONG                StarBufferSize[MAXELEMENTS + 1];
  88.  
  89. // from rp.c
  90. IMPORT struct Library      *WindowBase,
  91.                            *LayoutBase,
  92.                            *ButtonBase,
  93.                            *TextEditorBase,
  94.                            *LabelBase;
  95. IMPORT ABOOL                pal;
  96. IMPORT SBYTE                page;
  97. IMPORT ULONG                elements;
  98. IMPORT ULONG                returncode, inputs;
  99. IMPORT APTR                 OldWindowPtr;
  100. IMPORT struct Screen*       ScreenPtr;
  101. IMPORT struct Process*      ProcessPtr;
  102. IMPORT struct ReportStruct  report;
  103. IMPORT struct AutodocStruct autodoc;
  104. IMPORT struct NewGadget     Gadget; // only for the Gadget.ng_TextAttr field
  105. IMPORT struct List          ResultList;
  106.  
  107. MODULE struct Gadget*       gadgets[GID_LAST];
  108. MODULE        Object*       objects[OID_LAST];
  109. MODULE ABOOL                done;
  110. MODULE struct Window*       ReActionWindowPtr = NULL;
  111.  
  112. AGLOBAL void textedit(void)
  113. {   struct MsgPort* AppPort;
  114.  
  115.     TEXT            GadTitle[MAXELEMENTS + 1][VLONGFIELD + 1];
  116.     ULONG           i, theindex, wrapsize;
  117.  
  118.     struct TagItem  windowtag[12],
  119.                     rootlayouttag[7],
  120.                     bothlayouttag[8],
  121.                     supercaptiontag[8],
  122.                     subcaptiontag[3],
  123.                     texteditortag[4],
  124.                     buttontag[4],
  125.                      leftlayouttag[4 + (3 * (MAXELEMENTS + 1))],
  126.                     rightlayouttag[4 + (3 * (MAXELEMENTS + 1))];
  127.  
  128.     if (page == 11)
  129.     {   wrapsize = 75;
  130.         switch(report.type)
  131.         {
  132.         case BUG:
  133.             strcpy(GadTitle[0], "Brief bug description:");
  134.             strcpy(GadTitle[1], "Bug generation procedure or example:");
  135.             strcpy(GadTitle[2], "If this works differently on other versions or hardware, explain:");
  136.             strcpy(GadTitle[3], "Related problems:");
  137.             elements = 3;
  138.         break;
  139.         case COM:
  140.             if (report.severity == 3)
  141.             {   strcpy(GadTitle[0], "If this works differently on other versions or hardware, explain:");
  142.                 elements = 0;
  143.             } else
  144.             {   strcpy(GadTitle[0], "Brief bug description:");
  145.                 strcpy(GadTitle[1], "Bug generation procedure or example:");
  146.                 strcpy(GadTitle[2], "If this works differently on other versions or hardware, explain:");
  147.                 strcpy(GadTitle[3], "What developer is doing in that area of software or hardware:");
  148.                 strcpy(GadTitle[4], "Related problems:");
  149.                 elements = 4;
  150.             }
  151.         break;
  152.         case ENH:
  153.             strcpy(GadTitle[0], "Enhancement request:");
  154.             elements = 0;
  155.         break;
  156.         default:
  157.         break;
  158.     }   }
  159.     else
  160.     {   // assert(page == 41);
  161.         strcpy(GadTitle[0], "Function:");
  162.  
  163.         if (inputs)
  164.         {   for (i = 1; i <= inputs; i++)
  165.             {   strcpy(GadTitle[i], autodoc.var[i].name);
  166.                 strcat(GadTitle[i], ":");
  167.         }   }
  168.         if (returncode)
  169.         {   strcpy(GadTitle[inputs + 1], "Result:");
  170.         }
  171.         strcpy(GadTitle[inputs + 1 + returncode], "Example:");
  172.         strcpy(GadTitle[inputs + 2 + returncode], "Notes:");
  173.         strcpy(GadTitle[inputs + 3 + returncode], "Bugs:");
  174.         strcpy(GadTitle[inputs + 4 + returncode], "See Also:");
  175.         elements =      inputs + 4 + returncode;
  176.         wrapsize = 72;
  177.     }
  178.  
  179.     /* window
  180.         root-layout
  181.          both-layout
  182.           left-layout
  183.            super-caption
  184.             sub-caption
  185.            texteditor
  186.           [right-layout
  187.            super-caption
  188.             sub-caption
  189.            texteditor]
  190.          button */
  191.  
  192.     if (AppPort = CreateMsgPort())
  193.     {   /* Create the window object. */
  194.  
  195.         subcaptiontag[0].ti_Tag     = LABEL_Text;
  196.         // subcaptiontag[0].ti_Data filled later
  197.         subcaptiontag[1].ti_Tag     = LABEL_Justification;
  198.         subcaptiontag[1].ti_Data    = LJ_CENTRE;
  199.         subcaptiontag[2].ti_Tag     = TAG_END;
  200.  
  201.         texteditortag[0].ti_Tag  = GA_ID;
  202.         // texteditortag[0].ti_Data filled later
  203.         texteditortag[1].ti_Tag  = GA_RelVerify;
  204.         texteditortag[1].ti_Data = TRUE;
  205.         texteditortag[2].ti_Tag  = GA_TEXTEDITOR_ExportWrap;
  206.         texteditortag[2].ti_Data = wrapsize;
  207.         texteditortag[3].ti_Tag  = TAG_END;
  208.  
  209.         buttontag[0].ti_Tag      = GA_ID;
  210.         buttontag[0].ti_Data     = GID_OK;
  211.         buttontag[1].ti_Tag      = GA_RelVerify;
  212.         buttontag[1].ti_Data     = TRUE;
  213.         buttontag[2].ti_Tag      = GA_Text;
  214.         buttontag[2].ti_Data     = (ULONG) "_OK";
  215.         buttontag[3].ti_Tag      = TAG_END;
  216.  
  217.         supercaptiontag[0].ti_Tag  = LAYOUT_Orientation;
  218.         supercaptiontag[0].ti_Data = LAYOUT_ORIENT_VERT;
  219.         supercaptiontag[1].ti_Tag  = GA_BackFill;
  220.         supercaptiontag[1].ti_Data = NULL;
  221.         supercaptiontag[2].ti_Tag  = LAYOUT_SpaceOuter;
  222.         supercaptiontag[2].ti_Data = TRUE;
  223.         supercaptiontag[3].ti_Tag  = LAYOUT_VertAlignment;
  224.         supercaptiontag[3].ti_Data = LALIGN_CENTER;
  225.         supercaptiontag[4].ti_Tag  = LAYOUT_HorizAlignment;
  226.         supercaptiontag[4].ti_Data = LALIGN_CENTER;
  227.         supercaptiontag[5].ti_Tag  = LAYOUT_BevelStyle;
  228.         supercaptiontag[5].ti_Data = BVS_FIELD;
  229.         supercaptiontag[6].ti_Tag  = LAYOUT_AddImage;
  230.         // supercaptiontag[6].ti_Data filled later
  231.         supercaptiontag[7].ti_Tag  = TAG_END;
  232.  
  233.     leftlayouttag[0].ti_Tag  = LAYOUT_Orientation;
  234.     leftlayouttag[0].ti_Data = LAYOUT_ORIENT_VERT;
  235.     leftlayouttag[1].ti_Tag  = LAYOUT_SpaceOuter;
  236.     leftlayouttag[1].ti_Data = TRUE;
  237.     leftlayouttag[2].ti_Tag  = LAYOUT_DeferLayout;
  238.     leftlayouttag[2].ti_Data = TRUE;
  239.     theindex = 3;
  240.  
  241.     if (page == 41)
  242.     {   for (i = 0; i <= elements / 2; i++)
  243.         {   subcaptiontag[0].ti_Data          = (ULONG) GadTitle[i];
  244.             texteditortag[0].ti_Data          = GID_TEXTEDITOR1 + i;
  245.             supercaptiontag[6].ti_Data        = (ULONG) NewObjectA(LABEL_GetClass(), NULL, subcaptiontag);
  246.             leftlayouttag[theindex].ti_Tag    = LAYOUT_AddChild;
  247.             leftlayouttag[theindex++].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, supercaptiontag);
  248.             leftlayouttag[theindex].ti_Tag    = CHILD_WeightedHeight;
  249.             leftlayouttag[theindex++].ti_Data = 0;
  250.             leftlayouttag[theindex].ti_Tag    = LAYOUT_AddChild;
  251.             gadgets[GID_TEXTEDITOR1 + i]      = NewObjectA(TEXTEDITOR_GetClass(), NULL, texteditortag);
  252.             leftlayouttag[theindex++].ti_Data = (ULONG) gadgets[GID_TEXTEDITOR1 + i];
  253.         }
  254.         leftlayouttag[theindex].ti_Tag        = TAG_END;
  255.  
  256.         rightlayouttag[0].ti_Tag  = LAYOUT_Orientation;
  257.         rightlayouttag[0].ti_Data = LAYOUT_ORIENT_VERT;
  258.         rightlayouttag[1].ti_Tag  = LAYOUT_SpaceOuter;
  259.         rightlayouttag[1].ti_Data = TRUE;
  260.         rightlayouttag[2].ti_Tag  = LAYOUT_DeferLayout;
  261.         rightlayouttag[2].ti_Data = TRUE;
  262.         theindex = 3;
  263.         for (i = (elements / 2) + 1; i <= elements; i++)
  264.         {   subcaptiontag[0].ti_Data           = (ULONG) GadTitle[i];
  265.             texteditortag[0].ti_Data           = GID_TEXTEDITOR1 + i;
  266.             supercaptiontag[6].ti_Data         = (ULONG) NewObjectA(LABEL_GetClass(), NULL, subcaptiontag);
  267.             rightlayouttag[theindex].ti_Tag    = LAYOUT_AddChild;
  268.             rightlayouttag[theindex++].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, supercaptiontag);
  269.             rightlayouttag[theindex].ti_Tag    = CHILD_WeightedHeight;
  270.             rightlayouttag[theindex++].ti_Data = 0;
  271.             rightlayouttag[theindex].ti_Tag    = LAYOUT_AddChild;
  272.             gadgets[GID_TEXTEDITOR1 + i]       = NewObjectA(TEXTEDITOR_GetClass(), NULL, texteditortag);
  273.             rightlayouttag[theindex++].ti_Data = (ULONG) gadgets[GID_TEXTEDITOR1 + i];
  274.         }
  275.         rightlayouttag[theindex].ti_Tag        = TAG_END;
  276.     } else
  277.     {   for (i = 0; i <= elements; i++)
  278.         {   subcaptiontag[0].ti_Data          = (ULONG) GadTitle[i];
  279.             texteditortag[0].ti_Data          = GID_TEXTEDITOR1 + i;
  280.             supercaptiontag[6].ti_Data        = (ULONG) NewObjectA(LABEL_GetClass(), NULL, subcaptiontag);
  281.             leftlayouttag[theindex].ti_Tag    = LAYOUT_AddChild;
  282.             leftlayouttag[theindex++].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, supercaptiontag);
  283.             leftlayouttag[theindex].ti_Tag    = CHILD_WeightedHeight;
  284.             leftlayouttag[theindex++].ti_Data = 0;
  285.             leftlayouttag[theindex].ti_Tag    = LAYOUT_AddChild;
  286.             gadgets[GID_TEXTEDITOR1 + i]      = NewObjectA(TEXTEDITOR_GetClass(), NULL, texteditortag);
  287.             leftlayouttag[theindex++].ti_Data = (ULONG) gadgets[GID_TEXTEDITOR1 + i];
  288.         }
  289.         leftlayouttag[theindex].ti_Tag        = TAG_END;
  290.     }
  291.  
  292.     /* The captions are as wide as required to hold the entire caption on
  293.     one line. In many cases this means that `double-column' mode cannot be
  294.     used, as the right column would be pushed out too far to the right,
  295.     and partially offscreen. */
  296.  
  297.     bothlayouttag[0].ti_Tag  = LAYOUT_Orientation;
  298.     bothlayouttag[0].ti_Data = LAYOUT_ORIENT_HORIZ;
  299.     bothlayouttag[1].ti_Tag  = LAYOUT_SpaceOuter;
  300.     bothlayouttag[1].ti_Data = TRUE;
  301.     bothlayouttag[2].ti_Tag  = LAYOUT_DeferLayout;
  302.     bothlayouttag[2].ti_Data = TRUE;
  303.  
  304.     bothlayouttag[3].ti_Tag  = LAYOUT_AddChild;
  305.     bothlayouttag[3].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, leftlayouttag);
  306.     bothlayouttag[4].ti_Tag  = CHILD_WeightedWidth;
  307.     bothlayouttag[4].ti_Data = 50;
  308.     if (page == 41)
  309.     {   bothlayouttag[5].ti_Tag  = LAYOUT_AddChild;
  310.         bothlayouttag[5].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, rightlayouttag);
  311.         bothlayouttag[6].ti_Tag  = CHILD_WeightedWidth;
  312.         bothlayouttag[6].ti_Data = 50;
  313.         bothlayouttag[7].ti_Tag  = TAG_END;
  314.     } else
  315.         bothlayouttag[5].ti_Tag  = TAG_END;
  316.  
  317.         rootlayouttag[0].ti_Tag  = LAYOUT_Orientation;
  318.         rootlayouttag[0].ti_Data = LAYOUT_ORIENT_VERT;
  319.         rootlayouttag[1].ti_Tag  = LAYOUT_SpaceOuter;
  320.         rootlayouttag[1].ti_Data = TRUE;
  321.         rootlayouttag[2].ti_Tag  = LAYOUT_DeferLayout;
  322.         rootlayouttag[2].ti_Data = TRUE;
  323.         rootlayouttag[3].ti_Tag  = LAYOUT_AddChild;
  324.         rootlayouttag[3].ti_Data = (ULONG) NewObjectA(LAYOUT_GetClass(), NULL, bothlayouttag);
  325.         rootlayouttag[4].ti_Tag  = LAYOUT_AddChild;
  326.         rootlayouttag[4].ti_Data = (ULONG) NewObjectA(NULL, "button.gadget", buttontag);
  327.         rootlayouttag[5].ti_Tag  = CHILD_WeightedHeight;
  328.         rootlayouttag[5].ti_Data = 0;
  329.         rootlayouttag[6].ti_Tag  = TAG_END;
  330.  
  331.         if (pal)
  332.         {   windowtag[0].ti_Tag  = WA_CustomScreen;
  333.             windowtag[0].ti_Data = (ULONG) ScreenPtr;
  334.         } else
  335.         {   if (!(ScreenPtr = LockPubScreen(NULL)))
  336.                 rq("Can't lock default public screen!");
  337.             windowtag[0].ti_Tag  = WA_PubScreen;
  338.             windowtag[0].ti_Data = (ULONG) ScreenPtr;
  339.         }
  340.         windowtag[1].ti_Tag   = WA_ScreenTitle;
  341.         windowtag[1].ti_Data  = (ULONG) "Report+";
  342.         windowtag[2].ti_Tag   = WA_Title;
  343.         windowtag[2].ti_Data  = (ULONG) "Report+: Text Editor";
  344.         windowtag[3].ti_Tag   = WA_Activate;
  345.         windowtag[3].ti_Data  = TRUE;
  346.         windowtag[4].ti_Tag   = WA_DepthGadget;
  347.         windowtag[4].ti_Data  = TRUE;
  348.         windowtag[5].ti_Tag   = WA_DragBar;
  349.         windowtag[5].ti_Data  = TRUE;
  350.         windowtag[6].ti_Tag   = WA_CloseGadget;
  351.         windowtag[6].ti_Data  = TRUE;
  352.         windowtag[7].ti_Tag   = WA_SizeGadget;
  353.         windowtag[7].ti_Data  = TRUE;
  354.         windowtag[8].ti_Tag   = WINDOW_AppPort;
  355.         windowtag[8].ti_Data  = (ULONG) AppPort;
  356.         windowtag[9].ti_Tag   = WINDOW_Position;
  357.         windowtag[9].ti_Data  = WPOS_FULLSCREEN;
  358.         windowtag[10].ti_Tag  = WINDOW_ParentGroup;
  359.         gadgets[GID_MAIN]     = NewObjectA(LAYOUT_GetClass(), NULL, rootlayouttag);
  360.         windowtag[10].ti_Data = (ULONG) gadgets[GID_MAIN];
  361.         windowtag[11].ti_Tag  = TAG_END;
  362.  
  363.         objects[OID_MAIN] = NewObjectA(WINDOW_GetClass(), NULL, windowtag);
  364.  
  365.         if (pal)
  366.         {   /* redirection of AmigaDOS system requesters */
  367.             OldWindowPtr = ProcessPtr->pr_WindowPtr;
  368.             ProcessPtr->pr_WindowPtr = (APTR) objects[OID_MAIN];
  369.         } else
  370.         {   UnlockPubScreen(NULL, ScreenPtr);
  371.             ScreenPtr = NULL;
  372.         }
  373.  
  374.         // Object creation successful?
  375.         if (objects[OID_MAIN])
  376.         {   // Open the window.
  377.             if (ReActionWindowPtr = (struct Window *) DoMethod(objects[OID_MAIN], WM_OPEN, NULL))
  378.             {   ULONG wait, signal, app = (1L << AppPort->mp_SigBit);
  379.                 ULONG result;
  380.                 UWORD code;
  381.  
  382.                 done = FALSE;
  383.  
  384.                 // Obtain the window wait signal mask.
  385.                 GetAttr(WINDOW_SigMask, objects[OID_MAIN], &signal);
  386.  
  387.                 // Do any necessary imports.
  388.                 if (page == 11)
  389.                 {   switch(report.type)
  390.                     {
  391.                     case BUG:
  392.                         SetGadgetAttrs
  393.                         (   gadgets[GID_TEXTEDITOR1],       ReActionWindowPtr, NULL,
  394.                             GA_TEXTEDITOR_Contents,         report.textfield[0]
  395.                         ); // brief bug description
  396.                         SetGadgetAttrs
  397.                         (   gadgets[GID_TEXTEDITOR1 + 1],   ReActionWindowPtr, NULL,
  398.                             GA_TEXTEDITOR_Contents,         report.textfield[1]
  399.                         ); // bug generation procedure or example
  400.                         SetGadgetAttrs
  401.                         (   gadgets[GID_TEXTEDITOR1 + 2],   ReActionWindowPtr, NULL,
  402.                             GA_TEXTEDITOR_Contents,         report.textfield[2]
  403.                         ); // if this works differently...
  404.                         SetGadgetAttrs
  405.                         (   gadgets[GID_TEXTEDITOR1 + 3],   ReActionWindowPtr, NULL,
  406.                             GA_TEXTEDITOR_Contents,         report.textfield[3]
  407.                         ); // related problems
  408.                     break;
  409.                     case COM:
  410.                         if (report.severity == 0)
  411.                         {   SetGadgetAttrs
  412.                             (   gadgets[GID_TEXTEDITOR1],   ReActionWindowPtr, NULL,
  413.                                 GA_TEXTEDITOR_Contents,     report.textfield[2]
  414.                             ); // if this works differently...
  415.                         } else
  416.                         {   for (i = 0; i <= 4; i++)
  417.                             {   SetGadgetAttrs
  418.                                 (   gadgets[GID_TEXTEDITOR1 + i], ReActionWindowPtr, NULL,
  419.                                     GA_TEXTEDITOR_Contents,       report.textfield[i]
  420.                                 );
  421.                         }   }
  422.                         /* brief bug description
  423.                            bug generation procedure or example
  424.                            if this works differently...
  425.                            what developer is doing...
  426.                            related problems */
  427.                     break;
  428.                     case ENH:
  429.                         SetGadgetAttrs
  430.                         (   gadgets[GID_TEXTEDITOR1],       ReActionWindowPtr, NULL,
  431.                             GA_TEXTEDITOR_Contents,         report.textfield[5]
  432.                         ); // enhancement request
  433.                     break;
  434.                     default:
  435.                         ; // assert(0);
  436.                     break;
  437.                 }   }
  438.                 else
  439.                 {   // assert(page == 41);
  440.                     /* Autodoc text fields are as follows:
  441.                      0 Function
  442.                      1 Example
  443.                      2 Notes
  444.                      3 Bugs
  445.                      4 See also
  446.                      5 Result   (mirrors autodoc.var[0].desc)
  447.                   6-13 Inputs   (
  448.  
  449.                     Whereas the gadgets go Function, inputs, Result, others
  450.  
  451.                     */
  452.  
  453.                     SetGadgetAttrs
  454.                     (   gadgets[GID_TEXTEDITOR1],       ReActionWindowPtr, NULL,
  455.                         GA_TEXTEDITOR_Contents,         autodoc.textfield[0]
  456.                     );
  457.  
  458.                     if (inputs)
  459.                     {   for (i = 1; i < inputs; i++)
  460.                         {   SetGadgetAttrs
  461.                             (   gadgets[GID_TEXTEDITOR1 + i], ReActionWindowPtr, NULL,
  462.                                 GA_TEXTEDITOR_Contents, autodoc.var[i].desc
  463.                             );
  464.                     }   }
  465.                     if (returncode)
  466.                     {   SetGadgetAttrs
  467.                         (   gadgets[GID_TEXTEDITOR1 + inputs + 1], ReActionWindowPtr, NULL,
  468.                             GA_TEXTEDITOR_Contents,     autodoc.var[0].desc
  469.                         ); // return code
  470.                     }
  471.                     for (i = 1; i <= 4; i++)
  472.                     {   SetGadgetAttrs
  473.                         (   gadgets[GID_TEXTEDITOR1 + inputs + returncode + i], ReActionWindowPtr, NULL,
  474.                             GA_TEXTEDITOR_Contents,     autodoc.textfield[i]
  475.                         );
  476.                 }   }
  477.  
  478.                 // Activate the first texteditor gadget.
  479.                 ActivateLayoutGadget(gadgets[GID_MAIN], ReActionWindowPtr, NULL, (Object) gadgets[GID_TEXTEDITOR1]);
  480.  
  481.                 // Input Event Loop
  482.                 while (!done)
  483.                 {   wait = Wait( signal | SIGBREAKF_CTRL_C | app );
  484.  
  485.                     if ( wait & SIGBREAKF_CTRL_C )
  486.                         done = TRUE;
  487.                     else
  488.                     {   while ( (result = RA_HandleInput(objects[OID_MAIN], &code) ) != WMHI_LASTMSG )
  489.                         {   switch (result & WMHI_CLASSMASK)
  490.                             {
  491.                             case WMHI_CLOSEWINDOW:
  492.                                 ReActionWindowPtr = NULL;
  493.                                 done = TRUE;
  494.                             break;
  495.                             case WMHI_GADGETUP:
  496.                                 switch (result & WMHI_GADGETMASK)
  497.                                 {
  498.                                 case GID_OK:
  499.                                     done = TRUE;
  500.                                 break;
  501.                                 default:
  502.                                 break;
  503.                                 }
  504.                             break;
  505.                             default:
  506.                             break;
  507.             }   }   }   }   }
  508.  
  509.             for (i = 0; i <= elements; i++)
  510.                 textBuffer[i] = (STRPTR) DoGadgetMethod(gadgets[GID_TEXTEDITOR1 + i], ReActionWindowPtr, NULL, GM_TEXTEDITOR_ExportText, NULL);
  511.  
  512.             if (page == 11)
  513.             {   switch(report.type)
  514.                 {
  515.                 case BUG:
  516.                     strcpy(report.textfield[0], textBuffer[0]); // brief bug description
  517.                     strcpy(report.textfield[1], textBuffer[1]); // bug generation procedure or example
  518.                     strcpy(report.textfield[2], textBuffer[2]); // if this works differently...
  519.                     strcpy(report.textfield[4], textBuffer[3]); // related problems
  520.                 break;
  521.                 case COM:
  522.                     if (report.severity == 0)
  523.                     {   strcpy(report.textfield[2], textBuffer[0]); // if this works differently...
  524.                     } else
  525.                     {   strcpy(report.textfield[0], textBuffer[0]); // brief bug description
  526.                         strcpy(report.textfield[1], textBuffer[1]); // bug generation procedure or example
  527.                         strcpy(report.textfield[2], textBuffer[2]); // if this works differently...
  528.                         strcpy(report.textfield[3], textBuffer[3]); // what developer is doing...
  529.                         strcpy(report.textfield[4], textBuffer[4]); // related problems
  530.                     }
  531.                 break;
  532.                 case ENH:
  533.                     strcpy(report.textfield[5], textBuffer[0]); // enhancement request
  534.                 break;
  535.                 default:
  536.                     ; // assert(0);
  537.                 break;
  538.             }   }
  539.             else
  540.             {   // assert(page == 41);
  541.                 strcpy(autodoc.textfield[0], textBuffer[0]); // function
  542.                 if (inputs)
  543.                 {   for (i = 1; i <= inputs; i++)
  544.                     {   strcpy(autodoc.var[i].desc, textBuffer[i]);
  545.                 }   }
  546.                 if (returncode)
  547.                 {   strcpy(autodoc.var[0].desc, textBuffer[inputs + 1]);
  548.                 }
  549.                 for (i = 1; i <= 4; i++)
  550.                 {   strcpy(autodoc.textfield[i], textBuffer[inputs + returncode + i]);
  551.                 }
  552.  
  553.                 /* Qty  Field type
  554.                      1  Function field
  555.                    0-8  Input # fields
  556.                 0 or 1  Return code field
  557.                      1  Example field
  558.                      1  Notes field
  559.                      1  Bugs field
  560.                      1  See also field */
  561.             }
  562.  
  563.             for (i = 0; i <= elements; i++)
  564.             {   FreeVec((APTR) textBuffer[i]);
  565.                 textBuffer[i] = NULL;
  566.             }
  567.     
  568.             /* Disposing of the window object will also close the window if it is
  569.              * already opened, and it will dispose of the layout object attached to it.
  570.              */
  571.             DisposeObject(objects[OID_MAIN]);
  572.         } else rq("Report+: Can't create ReAction objects!");
  573.         DeleteMsgPort(AppPort);
  574.     } else rq("Report+: Can't create window message port!");
  575.  
  576.     return;
  577. }
  578.  
  579. /* AGLOBAL void InitHook(struct Hook* hook, ULONG (*func)(), void* data)
  580. {   // Make sure a pointer was passed
  581.     if (hook)
  582.     {   // Fill in the Hook fields
  583.         hook->h_Entry    = (ULONG (*) ()) HookEntry;
  584.         hook->h_SubEntry = func;
  585.         hook->h_Data     = data;
  586. }   } */
  587.